import request from '@/utils/request'
import MODULE from '@/utils/module'

export function getList(data, currentPage, pageSize) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/list?pageSize=' + pageSize + '&pageNum=' + currentPage,
    method: 'post',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function doDelete(id) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/remove',
    method: 'delete',
    params: { id }
  })
}

// 编辑
export function doEdit(data) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/edit',
    method: 'PATCH',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 指派与更新
export function assignAndModifyOrganAuthority(data, tenantId, organId) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/assignAndModify/'+tenantId+"/" + organId,
    method: 'PUT',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

// 获取组织的权限
export function assignedAuthorities(data, organId) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/assignedAuthorities/' + organId,
    method: 'GET',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


// 获取组织类型指定权限及未指定权限
export function getOriginAssignedAuthorities( data, originId, organId ) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/getOriginAssignedAuthorities/'+originId+'/'+organId,
    method: 'POST',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}



// 获取组织类型指定权限及未指定权限
export function getOrganAuthoritiesAndAssigned( data) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/getOrganAuthoritiesAndAssigned',
    method: 'POST',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}



//获取组织拥有的权限
export function getOrganAuthorities(data) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/getOrganAuthorities',
    method: 'post',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}


// 调整租户组织菜单
export function doAdjust(data) {
  return request({
    url: MODULE.MODULE.organAuthority + '/OrganAuthority/adjustOrganAuthorities',
    method: 'PATCH',
    params: {},
    data: data,
    transformRequest: [function(data) { // 在请求之前对data传参进行格式转换
      data = JSON.stringify(data)
      return data
    }],
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}




